package cn.itcast.bos.service.base.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.itcast.bos.dao.base.CourierRepository;
import cn.itcast.bos.domain.base.Courier;
import cn.itcast.bos.service.base.CourierService;

@Service
@Transactional
public class CourierServiceImpl implements CourierService {

	@Autowired
	private CourierRepository courierRepository;

	@Override
	public void save(Courier courier) {
		courierRepository.save(courier);
	}

	@Override
	public Page<Courier> findByPage(Specification<Courier> specification, Pageable pageAble) {
		
		return courierRepository.findAll(specification, pageAble);
	}

	@Override
	public void delCourier(String ids) {
		String[] arr = ids.split(",");
		for (int i = 0; i < arr.length; i++) {
			Integer id = Integer.parseInt(arr[i]);
			courierRepository.updateDeltag(id);
		}
	}
}
